function setCookie(name,val,day,path="/"){
    if(day){
        var date=new Date();
        date.setDate(date.getDate()+day)//在原本的日期上加7天
        document.cookie=name+"="+encodeURIComponent(val)+";expires="+date.toUTCString()+";path="+path+";"
    }else{
        document.cookie=name+"="+encodeURIComponent(val)+";expires"+";path="+path+";"
    }
}




function getCookie(key){
    var cookie=document.cookie//获取cookie
    if(cookie){
        var dataList=cookie.split("; ")//将字符串拆分成数组
       for(var i=0;i<dataList.length;i++){
           var item=dataList[i]//获取数组某项
           var arr=item.split('=')//将获取的数组某项拆分成一个数组长度位2的数组
           var name=arr[0]//获取某项cookie的键名
           var val=arr[1]//获取某项cookie的键值
           if(key===name){
            return decodeURIComponent(val)
           }
       }
    }
}

function deCookie(key){
    setCookie(key,"",-1)
}